/**
 * 
 */
package cn.agiledata.bank.audit.logic;

import cn.agiledata.bank.hibernateBean.AuditOperation;
import cn.agiledata.bank.hibernateBean.HistoryAuditOperation;
import cn.agiledata.bank.hibernateBean.RecentAuditOperation;

/**
 * @author 马贤波
 * 
 */
public class HistoryAuditOperationWrapper extends AuditOperationWrapper {

    public static final long PRIMARY_SEQUENCE_NO = 0;

    public HistoryAuditOperationWrapper(AuditOperation auditOperation) {
        super(auditOperation);
    }

    /**
     * 根据指定的RecentAuditOperation对象生成对应的HistoryAuditOperation对象。
     * 
     * @param sequenceNo
     *            the sequenceNo of the new HistoryAuditOperation object
     * @param recentAuditOperation
     *            the RecentAuditOperation object
     * @return new HistoryAuditOperation object
     */
    public static HistoryAuditOperation getHistoryAuditOperation(
            long sequenceNo, RecentAuditOperation recentAuditOperation) {
        HistoryAuditOperation historyOperation = new HistoryAuditOperation();
        historyOperation.setSequenceNo(sequenceNo);
        historyOperation.setAuditGroup(recentAuditOperation.getAuditGroup());
        historyOperation.setAuditRule(recentAuditOperation.getAuditRule());
        historyOperation.setAuditOperandId(recentAuditOperation
                .getAuditOperandId());
        historyOperation.setPreviousStatus(recentAuditOperation
                .getPreviousStatus());
        historyOperation.setPostStatus(recentAuditOperation.getPostStatus());
        historyOperation.setCreateUser(recentAuditOperation.getCreateUser());
        historyOperation.setCreateTime(recentAuditOperation.getCreateTime());
        historyOperation.setUpdateUser(recentAuditOperation.getUpdateUser());
        historyOperation.setUpdateTime(recentAuditOperation.getUpdateTime());
        historyOperation.setAttitude(recentAuditOperation.getAttitude());
        historyOperation.setVersion(recentAuditOperation.getVersion());
        return historyOperation;
    }

    public long nextAuditSequenceNo() {
        HistoryAuditOperation historyOperation = (HistoryAuditOperation) this
                .getAuditOperation();
        return historyOperation == null ? PRIMARY_SEQUENCE_NO
                : historyOperation.getSequenceNo() + 1;
    }

}
